package com.ruoyi.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.business.app.vo.HomeBannerVo;
import com.ruoyi.business.domain.HcxBanner;
import com.ruoyi.business.service.IHcxBannerService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @author: kubilewang
 * @date: 2022/8/19
 * @param: 
 * @Return: 
**/
@Api(tags = "轮播图管理")
@RestController
@RequestMapping("/api")
@AllArgsConstructor
public class BannerController {

    private IHcxBannerService bannerService;


    @ApiOperation(value = "banner图列表")
    @GetMapping("/banners/list")
    public AjaxResult<List<HomeBannerVo>> banner() {
        List<HomeBannerVo> homeBannerVos = bannerService.listVo(new LambdaQueryWrapper<HcxBanner>().orderByAsc(HcxBanner::getPicSort), HomeBannerVo.class);
        return AjaxResult.success(homeBannerVos);
    }

    @ApiOperation(value = "banner详情")
    @GetMapping("/banner/detail")
    public AjaxResult<HomeBannerVo> bannerDetail(@ApiParam(value = "主键",required = true)Long id) {
        HomeBannerVo vo = bannerService.getVoOne(new LambdaQueryWrapper<HcxBanner>().eq(HcxBanner::getId, id), HomeBannerVo.class);
        return AjaxResult.success(vo);
    }
}
